extends "../ib.gd"

#根据等级增加属性
func addatt():
	if self.id.find("MAX") != -1:
		att.maxHp += 300
		att.atk += 20
	else:
		att.maxHp += 100
		att.atk += 10
	pass
#链接信号
func _connect():
	._connect()
	yield(sys.get_tree().create_timer(0.1),"timeout")
	if !masCha:return
	if !masCha.is_connected("onAddItem",self,"check"):
		#print(1)
		masCha.connect("onAddItem",self,"check")

#判断是否升级及是否只有一个核心
func check(item):
	yield(sys.get_tree().create_timer(0.02),"timeout")
	if item.id.find("core") != -1 && item != self:
		if !item:return
		masCha.delItem(item)
		sys.newBaseMsg("提示","一个角色只能装备一个核心")

#进化装备
func upgradeself(item):
	var chose = item.chose
	var upid = ""
	upid = upid + "_Hide"
	if self.id == "i_TD_core_Hide":
		upid = "_MAX"
	upid = self.id + upid
	#self.switchchose(chose)
	var nitem = sys.newItem(upid)
	sys.main.player.addItem(nitem)
	masCha.disconnect("onAddItem",self,"check")
	masCha.addItem(nitem)
	nitem.inheritatt(nitem,self)
	nitem.addatt()
	nitem.switchchose(chose)
	nitem.upinfo()
	self.delself()
	
